using UnityEngine;
using System.Collections;

public class PlayerCharacter : MonoBehaviour 
{
	
public int moveSpeed = 140;
public int score = 0;
public string scoreText;
	// Use this for initialization
	void Start () 
	{
		scoreText = "Score: " + "0"; 
	}
	
	// Update is called once per frame
	void Update () 
	{
		
		Vector3 moveDirection = Vector3.zero;
		Vector3 newPosition = Vector3.zero;
		
		if(Input.GetKey(KeyCode.LeftArrow)) moveDirection.x -= 1;
		if(Input.GetKey(KeyCode.RightArrow)) moveDirection.x += 1;
		
		moveDirection = moveDirection * (moveSpeed * Time.deltaTime);
		newPosition = transform.position + moveDirection;
		newPosition.x = Mathf.Clamp(newPosition.x, -107, 126);
		transform.position = newPosition;
		
		
	}
	
	void OnGUI () 
	{
     	GUI.Label(new Rect (470, 10, 100, 20), scoreText);
	}
	
   void OnTriggerEnter(Collider other) 
	{
      	 audio.Play();
		 score += 100;
		 scoreText = "Score: " + score;	
	}
}
